
#include <stdio.h>
#include <stdint.h>

#define N 51

int array[N][N]; 
int f[2*N][N][N]; 

int max(int a, int b)
{
	return a>b ? a : b;
}

int max3(int a, int b, int c)
{
	return max(a, max(b, c)); 
}

int max4(int a, int b, int c, int d)
{
	return max(max(a, b), max(c, d)); 
}

int main()
{
	int m, n, sum; 
	int i, j, k, l; 
	int a, b, c, d; 
	
	scanf("%d %d", &m, &n); 
	for (i=1; i<=m; i++) {
		for (j=1; j<=n; j++) {
			scanf("%d", &array[i][j]); 
		}
	}	
	
	for (sum=2; sum<=m+n; sum++) {

		for (i=1; i<=m; i++) {
			for (k=1; k<=m; k++) {
				j=sum-i; 
				l=sum-k; 
				if (j<=0 || l<=0) {
					//printf("j=%d l=%d, line=%d\n", j, l, __LINE__); 
					continue; 
				}
				if (j>n || l>n) {
					//printf("j=%d l=%d, line=%d\n", j, l, __LINE__); 
					continue; 
				}
				if (k==i) {
					continue; 
				}
				a = f[sum-1][i-1][k-1]; 
				b = f[sum-1][i-1][k]; 
				c = f[sum-1][i][k-1]; 
				d = f[sum-1][i][k]; 
				f[sum][i][k] = max4(a, b, c, d); 
				f[sum][i][k] += array[i][j] + array[k][l]; 
				//printf("f[%d][%d][%d] = %d, j=%d, l=%d, ar[%d][%d]=%d ar[%d][%d]=%d abcd=(%d, %d, %d, %d)\n", 
				//		sum, i, k, f[sum][i][k], j, l, 
				//		i,j, array[i][j], k, l, array[k][l], a, b, c, d); 
				
			}
		}
	}	
	
	printf("%d\n", max(f[m+n-1][m-1][m], f[m+n-1][m][m-1])); 
	
	return 0; 
}



